package com.zzhou.linkinfo.clock.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.zzhou.linkinfo.clock.R;

import java.util.ArrayList;
import java.util.List;

/**
 * <desc>
 * Created by The Moss on 2018/8/6.
 */

public class TestListAdapter extends BaseAdapter {
    List<String> datas;

    public TestListAdapter(Context mContext) {
        super(mContext);
        this.datas = new ArrayList<>();
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        return new ViewHolder(LayoutInflater.from(mContext).inflate(R.layout.clock_test_item_view, parent, false));
    }

    @Override
    public int getItemCount() {
        return datas.size();
    }

    public void setDatas(List<String> datas) {
        this.datas.clear();
        this.datas.addAll(datas);
    }


    public class ViewHolder extends BaseViewHolder {
        TextView textView;
        public ViewHolder(View itemView) {
            super(itemView);
            textView = itemView.findViewById(R.id.textView);
        }

        @Override
        public void setData(int position) {
            textView.setText(datas.get(position));
        }
    }
}
